{include file="index/header" /}
<block name="css">
	<script type="text/javascript" charset="utf-8" src="__PUBLIC__admin/UEditor-admin/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="__PUBLIC__admin/UEditor-admin/ueditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8" src="__PUBLIC__admin/UEditor-admin/lang/zh-cn/zh-cn.js"></script>
</block>
<script type="text/javascript" src="__PUBLIC__admin/UEditor-admin/third-party/SyntaxHighlighter/shCore.js"></script>
<link rel="stylesheet" href="__PUBLIC__admin/UEditor-admin/third-party/SyntaxHighlighter/shCoreDefault.css">
<script type="text/javascript">
	SyntaxHighlighter.all();
</script>

<style type="text/css">.editor_content{display: none;}</style>
<body>
	<div class="panel admin-panel margin-top" id="add">
		<div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 问答点评</strong></div>
		<div class="body-content">
			<form method="post" class="form-x" action="" onsubmit="return submitForm()">
				<div class="form-group">
					<div class="label">
						<label>学生账户：</label>
					</div>
					<div class="label" style="width:5%;overflow:inherit">
						<label>{$user.know_remarks ?: $user.know_nickname}-{$user.know_phone ?: $user.know_email}</label>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>学生身份：</label>
					</div>
					<div class="label" style="width:5%;overflow:inherit">
						<label>{$data.user_type}</label>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>学生问答：</label>
					</div>
					<div class="field">
						{$data.content}
						<div class="col-md-8 col-md-offset-2"><a class="btn btn-success btn-sm pull-right" data-id="{$data.id}">修改</a></div>
					</div>
					<div class="editor_content">{$data.content}</div>
				</div>
				{foreach name='data.answers' item='a'}
				<div class="form-group">
					<div class="label">
						<label>{if $a.user_id eq '0'}老师点评{else}学生追问{/if}：</label>
					</div>
					<div class="field">
						{$a.content}
						<div class="col-md-8 col-md-offset-2"><a class="btn btn-success btn-sm pull-right" data-id="{$a.id}">修改</a></div>
					</div>
					<div class="editor_content">{$a.content}</div>
				</div>
				{/foreach}
				<div class="form-group">
					<div class="label">
						<label>是否解决：</label>
					</div>
					<div class="field">
						<div class="button-group radio">
							<label class="button {if $data.answer eq 1} active {/if}">
								<span class="icon icon-check"></span>
								<input name="answer" value="1" type="radio" {if $data.answer eq 1} checked="checked"{/if}>是
							</label>
							<label class="button {if $data.answer eq 0} active {/if}">
								<span class="icon icon-times"></span>
								<input name="answer" value="0"  type="radio" {if $data.answer eq 0}checked="checked"{/if}>否
							</label>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>是否负面：</label>
					</div>
					<div class="field">
						<div class="button-group radio">
							<label class="button {if $data.is_negative eq 'yes'} active {/if}">
								<span class="icon icon-check"></span>
								<input name="is_negative" value="yes" type="radio" {if $data.is_negative eq 'yes'}  checked="checked" {/if}>是
							</label>
							<label class="button {if $data.is_negative eq 'no'} active {/if}">
								<span class="icon icon-times"></span>
								<input name="is_negative" value="no"  type="radio" {if $data.is_negative eq 'no'}  checked="checked" {/if}>否
							</label> 
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>点评：</label>
					</div>
					<div class="field">
						<textarea name="content" id="editor" style="width:845px; height:460px;"></textarea>
						<div class="tips">点评</div>
					</div>
				</div>
				{notin name='22' value="$admin.role_id"}<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
					</div>
				</div>{/notin}
				<input type="hidden" name="course_id" value="{$data.course_id}">
				<input type="hidden" name="id" value="{$data.id}">
			</form>
		</div>
	</div>
	<script type="text/javascript">
		function submitForm(){
			$('.icon-check-square-o').attr('disabled','disabled');
			$('.icon-check-square-o').text('提交中');
			$('.icon-check-square-o').css('background-color','#d2d2d2');
		}
		var ue = UE.getEditor('editor');
		var num = 0;
		var ueChange = [];
		$(document).on('click','.pull-right',function(){
			var id = $(this).data('id');
			var content = $(this).parent().parent().next().html();
			$(this).parent().parent().html('<textarea name="choices[]" id="editor'+num+'" class="editor1" data-sort="'+num+'" style="width:529px; height:166px;">'+content+'</textarea><div class="col-md-8 col-md-offset-2"><a class="btn btn-success btn-sm pull-submit" data-id="'+id+'" data-num="'+num+'">提交</a><a class="btn btn-success btn-sm pull-cancel" data-id="'+id+'" style="background-color:#e20d0d">取消</a></div>');
			ueChange = editors(num);
			console.log(ueChange)
			num++;
		});
		$(document).on('click','.pull-cancel',function(){
			var id = $(this).data('id');
			var content = $(this).parent().parent().next().html();
			$(this).parent().parent().html(content+'<div class="col-md-8 col-md-offset-2"><a class="btn btn-success btn-sm pull-right" data-id="'+id+'">修改</a></div>');
		});
		$(document).on('click','.pull-submit',function(){
			var _ts = $(this);
			var id = $(this).data('id');
			var nums = $(this).data('num');
			var content = ueChange[''+nums+''].getContent();
			$.ajax({
				url:'/admin/user/changeQuestion',
				data:{'id':id,'content':content},
				type:"post",
				success:function(){
					_ts.parent().parent().next().html(content);
					console.log(_ts.parent().parent())
					_ts.parent().parent().html(content+'<div class="col-md-8 col-md-offset-2"><a class="btn btn-success btn-sm pull-right" data-id="'+id+'">修改</a></div>');
				}
			})
		});
		function editors(sort = ''){
			var ues = UE.getEditor('editor'+sort, {
				toolbars: [
					[
						'source', //源代码
						'bold', //加粗
						'italic', //斜体
						'underline', //下划线
						'subscript', //下标
						'superscript', //上标
						'removeformat', //清除格式
						'unlink', //取消链接
						'insertcode', //代码语言
						'fontfamily', //字体
						'fontsize', //字号
						'simpleupload', //单图上传
						'insertimage', //多图上传
						'link', //超链接
						'forecolor', //字体颜色
						'backcolor', //背景色
						'insertorderedlist', //有序列表
						'insertunorderedlist', //无序列表
						'imagecenter', //居中
						'inserttable', //插入表格
						'drafts', // 从草稿箱加载
					]
				],
				autoHeightEnabled: true,
				autoFloatEnabled: true
			});
			ueChange[''+sort+''] = ues;
			return ueChange;
		}
	</script>
</body></html>
